{
  "name": "Case 43: Lease Agreement Key-Date Extractor",
  "nodes": [
    {
      "parameters": {
        "pollTimes": { "item": [{ "mode": "everyMinute" }] },
        "folderToWatch": { "__rl": true, "value": "1KVYvmrXNW48iR_qTA438K4IsF4TbRb8y", "mode": "list" },
        "event": "fileCreated"
      },
      "id": "trigger_case_43",
      "name": "Lease Upload Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [-1100, 0]
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": { "__rl": true, "value": "={{ $json.id }}", "mode": "id" }
      },
      "id": "download_case_43",
      "name": "Download Lease",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [-900, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.cloud.llamaindex.ai/api/v1/parsing/upload",
        "sendHeaders": true,
        "headerParameters": { "parameters": [{ "name": "Authorization", "value": "Bearer llx-7BWYrvPwfUhgdXbZMtaNCsr2O0h7JH4dkHjHisxcvq46bkIj" }] },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": { "parameters": [{ "parameterType": "formBinaryData", "name": "file", "inputDataFieldName": "data" }] }
      },
      "id": "post_case_43",
      "name": "LlamaIndex Upload",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [-700, 0]
    },
    {
      "parameters": { "amount": 20 },
      "id": "wait_case_43",
      "name": "Wait for Parsing",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [-500, 0]
    },
    {
      "parameters": {
        "url": "=https://api.cloud.llamaindex.ai/api/v1/parsing/job/{{ $node[\"LlamaIndex Upload\"].json[\"id\"] }}",
        "sendHeaders": true,
        "headerParameters": { "parameters": [{ "name": "Authorization", "value": "Bearer llx-7BWYrvPwfUhgdXbZMtaNCsr2O0h7JH4dkHjHisxcvq46bkIj" }] }
      },
      "id": "check_case_43",
      "name": "Check Status",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [-300, 0]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            { "conditions": { "conditions": [{ "leftValue": "={{ $json.status }}", "rightValue": "SUCCESS", "operator": { "type": "string", "operation": "equals" } }] }, "renameOutput": true, "outputKey": "SUCCESS" },
            { "conditions": { "conditions": [{ "leftValue": "={{ $json.status }}", "rightValue": "PENDING", "operator": { "type": "string", "operation": "equals" } }] }, "renameOutput": true, "outputKey": "PENDING" }
          ]
        }
      },
      "id": "switch_case_43",
      "name": "Status Switch",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.3,
      "position": [-100, 0]
    },
    {
      "parameters": {
        "url": "=https://api.cloud.llamaindex.ai/api/v1/parsing/job/{{ $node[\"LlamaIndex Upload\"].json[\"id\"] }}/result/markdown",
        "sendHeaders": true,
        "headerParameters": { "parameters": [{ "name": "Authorization", "value": "Bearer llx-7BWYrvPwfUhgdXbZMtaNCsr2O0h7JH4dkHjHisxcvq46bkIj" }] }
      },
      "id": "markdown_case_43",
      "name": "Get Markdown",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [150, -100]
    },
    {
      "parameters": {
        "text": "={{ $json.markdown }}",
        "attributes": {
          "attributes": [
            { "name": "Property Name", "description": "The name or address of the leased premises (e.g., Cyber Towers)." },
            { "name": "Tenant Name", "description": "Legal entity name of the tenant." },
            { "name": "Lease Expiry Date", "description": "The date the initial lease term ends (YYYY-MM-DD)." },
            { "name": "Renewal Deadline", "description": "The explicit final date to give notice for renewal (YYYY-MM-DD)." },
            { "name": "Notice Period (Days)", "description": "Number of days notice required (e.g., 180)." },
            { "name": "Escalation Percentage", "description": "Annual rent increase percentage (e.g., 7.5%)." },
            { "name": "Facilities Manager Email", "description": "The email address for maintenance and renewal notices." }
          ]
        }
      },
      "id": "extractor_case_43",
      "name": "Lease Key-Date Extractor",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1.2,
      "position": [400, -100]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": { "__rl": true, "value": "YOUR_SHEET_ID_HERE", "mode": "list" },
        "sheetName": { "__rl": true, "value": "gid=0", "mode": "list" },
        "columns": { "mappingMode": "autoMapInputData" }
      },
      "id": "sheet_case_43",
      "name": "Log to Renewal Tracker",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [650, -100]
    },
    {
      "parameters": {
        "calendar": { "__rl": true, "value": "primary", "mode": "list" },
        "start": "={{ $node[\"Lease Key-Date Extractor\"].json.output[\"Renewal Deadline\"] }}T09:00:00Z",
        "end": "={{ $node[\"Lease Key-Date Extractor\"].json.output[\"Renewal Deadline\"] }}T09:30:00Z",
        "summary": "=Lease Renewal Deadline: {{ $node[\"Lease Key-Date Extractor\"].json.output[\"Property Name\"] }}",
        "description": "=Renewal notice due for {{ $node[\"Lease Key-Date Extractor\"].json.output[\"Property Name\"] }}. Contact: {{ $node[\"Lease Key-Date Extractor\"].json.output[\"Facilities Manager Email\"] }}",
        "additionalFields": {
          "attendees": "={{ $node[\"Lease Key-Date Extractor\"].json.output[\"Facilities Manager Email\"] }}"
        }
      },
      "id": "calendar_case_43",
      "name": "Create Calendar Invite",
      "type": "n8n-nodes-base.googleCalendar",
      "typeVersion": 1.2,
      "position": [850, -100]
    },
    {
      "parameters": {
        "model": { "__rl": true, "value": "gpt-4o-mini", "mode": "list" }
      },
      "id": "llm_case_43",
      "name": "GPT-4o",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [400, 100]
    }
  ],
  "connections": {
    "Lease Upload Trigger": { "main": [[{ "node": "Download Lease", "type": "main", "index": 0 }]] },
    "Download Lease": { "main": [[{ "node": "LlamaIndex Upload", "type": "main", "index": 0 }]] },
    "LlamaIndex Upload": { "main": [[{ "node": "Wait for Parsing", "type": "main", "index": 0 }]] },
    "Wait for Parsing": { "main": [[{ "node": "Check Status", "type": "main", "index": 0 }]] },
    "Check Status": { "main": [[{ "node": "Status Switch", "type": "main", "index": 0 }]] },
    "Status Switch": { "main": [[{ "node": "Get Markdown", "type": "main", "index": 0 }], [{ "node": "Wait for Parsing", "type": "main", "index": 0 }]] },
    "Get Markdown": { "main": [[{ "node": "Lease Key-Date Extractor", "type": "main", "index": 0 }]] },
    "Lease Key-Date Extractor": { "main": [[{ "node": "Log to Renewal Tracker", "type": "main", "index": 0 }]] },
    "Log to Renewal Tracker": { "main": [[{ "node": "Create Calendar Invite", "type": "main", "index": 0 }]] },
    "GPT-4o": { "ai_languageModel": [[{ "node": "Lease Key-Date Extractor", "type": "ai_languageModel", "index": 0 }]] }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": { "templateCredsSetupCompleted": true }
}